<?php
$http = new Swoole\Http\Server('0.0.0.0', 9501);
$http->set([
   'worker_num'=>1,
   'document_root'=>'/www/wwwroot/swoole/rpc',  //虚拟目录指向的位置 只针对静态资源 绝对路径
    'enable_static_handler'=>true
]);
$http->on('Request', function ($request, $response) {
    $response->status(404);
    $response->header('Content-Type', 'text/html; charset=utf-8');
    $response->end('<h1>Hello Swoole. #' . rand(1000, 9999) . '</h1>');
});

$http->start();